package com.ruoyi.common.utils.pay;

import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WXPay {

    @Bean
    public WxPayConfig payConfig() {
        WxPayConfig payConfig = new WxPayConfig();
        payConfig.setAppId("wx8d3341b4ba8df6ff");
        payConfig.setMchId("1480663642");
        payConfig.setMchKey("844257B867471DBF9690EBE24F7144ZA");
        payConfig.setKeyPath("classpath:apiclient_cert.p12");
        payConfig.setNotifyUrl("http://www.baidu.com/mobileUser/goodsList/weiXinBack");
        return payConfig;
    }

    @Bean
//    @ConditionalOnMissingBean
    public WxPayService wxPayService(WxPayConfig payConfig) {
        WxPayService wxPayService = new WxPayServiceImpl();
        wxPayService.setConfig(payConfig);
        return wxPayService;
    }
}
